﻿using Sino.CapacityCloud.WebApi;
using Sino.Tms.Primitives;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Threading.Tasks;

namespace Sino.CapacityCloud.Repositories.Models
{

    public class Order
        : IOrder<Order>
    {

        [Key()]
        [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
        public string OrderId { get; set; }

        public string OrderNumber { get; set; }

        public string UserId { get; set; }

        public string CarrierOrderId { get; set; }

        public string TransportLinkageId { get; set; }

        public double Amount { get; set; }

        public string AmountUnit { get; set; }

        public DateTime ArrivalTime { get; set; }

        public string CarCode { get; set; }

        public string CarLength { get; set; }

        public string Category { get; set; }

        public string ContactName { get; set; }

        public string ContactChatId { get; set; }

        public string ContactPhoneNumber { get; set; }

        public DateTime DeliveryTime { get; set; }

        public string GrabComment { get; set; }

        public bool IsFocus { get; set; }

        public string Price { get; set; }

        public OrderStatus State { get; set; }

        public double Emergency { get; set; }

        public string Remarks { get; set; }

        public OrderType Type { get; set; }

        public virtual TransportLinkage TransportLinkage { get; set; }

        public virtual ApplicationUser User { get; set; }

        public virtual Order Parent { get; set; }

        public virtual ICollection<Order> SubOrders { get; set; }

        [NotMapped]
        string IOrder<Order>.Id
        {
            get
            {
                return this.OrderId;
            }
            set
            {
                this.OrderId = value;
            }
        }

        public Order()
        {
            this.OrderId = Guid.NewGuid().ToString();
            this.SubOrders = new List<Order>();
        }

    }

}